

export function formatDate(date: Date){
  //console.log(date);
  if(date === undefined || date === null){
    return '';
  }
  const newDate = new Date( date );
  const year: number = newDate.getFullYear();
  const month: any = ( newDate.getMonth() + 1 ) < 10 ? '0' + ( newDate.getMonth() + 1 ) : ( newDate.getMonth() + 1 );
  const day: any = newDate.getDate() < 10 ? '0' + newDate.getDate() : newDate.getDate();
  return year + '-' + month + '-' + day;
}

export function orderCountTime(overtime) {
  
  //获取当前时间
  let h=0,m=0,s=0
  var date = new Date();
  var now = date.getTime();
  //设置截止时间
  var endDate = new Date(overtime);
  var end = endDate.getTime();
  //时间差
  var leftTime = end - now;
  //定义变量 d,h,m,s保存倒计时的时间
  if (leftTime >= 0) {
     
      h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
      m = Math.floor(leftTime / 1000 / 60 % 60);
      s = Math.floor(leftTime / 1000 % 60);
  }

  return `${h<10?'0'+h:h}:${m<10?'0'+m:m}:${s<10?'0'+s:s}`

  //递归每秒调用countTime方法，显示动态时间效果
 
}